package _19define;

import java.util.Arrays;

public class Demo4 {
    public static void main(String[] args) {
        String[] arr;
        arr = new String[]{"UxoEl", "If3js", "9SSwC", "czHuA", "lZLBF", "IhynX", "VgjrY", "dJAIW"};
        System.out.println("排序前:");
        System.out.println(Arrays.toString(arr));
        String[] newArr=abc(arr);
        System.out.println("排序后:");
        System.out.println(Arrays.toString(newArr));
    }
    public static String[] abc(String[] arr){
        int n= arr.length;
        //遍历数组中的字符串
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n-i-1; j++) {
                String a=(arr[j].substring(0,1).toLowerCase().charAt(0)>=arr[j+1].substring(0,1).toLowerCase().charAt(0))?arr[j]:arr[j+1];
                String b=(arr[j].substring(0,1).toLowerCase().charAt(0)>=arr[j+1].substring(0,1).toLowerCase().charAt(0))?arr[j+1]:arr[j];
                arr[j+1]=a;
                arr[j]=b;
            }
        }
        return arr;
    }
}
